package com.kaitian.demo.demo_boot_starter.runner;

import com.kaitian.demo.demo_boot_starter.dto.DemoDO;
import com.kaitian.demo.demo_boot_starter.service.IDemoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.redis.core.RedisOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author ：xietian
 * @version ：V1.0
 * @program ：demo
 * @date ：Created in 2022/4/8 15:57
 * @description ：
 */
@Slf4j
@Component
public class DemoRunner implements ApplicationRunner {

    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private IDemoService demoService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("项目启动后运行：{}", this.getClass().getSimpleName());
//        for (int i = 1; i <= 1; i++) {
//            demoService.printStr();
//        }
//        DemoDO dto = demoService.getById(1);
//        System.out.println(dto);
//        redisTemplate.opsForHash().put("demo_hash", dto.getId(), dto);
//        dto = (DemoDO) redisTemplate.opsForHash().get("demo_hash", dto.getId());
//        System.out.println(dto.getDemoText());

        log.info("测试调用方法完成！");
    }
}